//.net 新增功能接口
import axios from 'axios'
import { Message } from 'element-ui'
import qs from 'qs'

let  token =window.localStorage.getItem("token")

const service = axios.create({
  baseURL: 'https://impnetapi.wissdom.cn', 
  timeout: 300000,
  paramsSerializer: function (params) {
    return qs.stringify(params, {arrayFormat: 'indices'})
  },
  headers:{
    authorization:`Bearer ${token}`,
    timestamp: new Date().getTime().toString(),
  }
})

service.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

service.interceptors.response.use(
  response => {
    let data = response.data;
    if(data.code==200){
      return data
    }else{
      Message.error(data.info)
    }
    return response.data
  },
)

export default service
